const {domain, acid, version_number} = require('./config');
var app = getApp();

/**
 * 图片附件上传
 */
export function uploadfile(params, success, fail = null) {
    uni.request({
        url: domain + '/index?s=/admin/attachment/upload',
        method: 'POST',
        data: {
            ...params,
        	access_token: app.globalData.access_token
        },
        success: success,
        fail: fail
    });
}


/**
 * 微信登录-第一步
 */
export function userlogin(success, fail = null) {
    uni.login({
        success: (res) => {
            if (res.code) {
                uni.request({
                    method: 'POST',
                    url: domain + '/index.php?s=/admin/login/getWxapp',
                    data: {
                        code: res.code,
                        weixin_login_status: 1,
                        _acid: acid
                    },
                    success: (getWxappres) => {
                        success(getWxappres, res.code);
                    },
                    fail: fail
                });
            }
        }
    });
}

/**
 * 手机快捷登录 - 第二步-获取手机号码
 */
export function wxappgetphone(params, success, fail = null) {
    uni.request({
        url: domain + '/index.php?s=/shared/user.login/wxapp_getphone',
        method: 'POST',
        data: {
            ...params,
            _acid: acid
        },
        success: success,
        fail: fail
    });
}

/**
 * 手机快捷登录 - 第三步-手机登录
 */
export function mobileLogin(params, success, fail = null) {
    uni.request({
        url: domain + '/index.php?s=/admin/login/mobileLogin',
        method: 'POST',
        data: {
            ...params
        },
        success: success,
        fail: fail
    });
}

/**
 * 经营统计
 */
export function statisticsFromStoreId(params, success, fail = null) {
    uni.request({
        url: domain + '/index.php?s=/shared/store.index/statisticsFromStoreId',
        method: 'POST',
        data: {
            ...params,
			access_token: app.globalData.access_token
        },
        success: success,
        fail: fail
    });
}

/**
 * 门店列表
 */
export function mendianstatistics(params, success, fail = null) {
	console.log("token", app.globalData.access_token)
    uni.request({
        url: domain + '/index.php?s=/shared/platform.store/index',
        method: 'POST',
        data: {
            ...params,
			access_token: app.globalData.access_token
        },
        success: success,
        fail: fail
    });
}


/**
 * 订单列表
 */
export function cleaninglist(params, success, fail = null) {
    uni.request({
        url: domain + '/index.php?s=shared/platform.house_order/index',
        method: 'POST',
        data: {
            ...params,
            access_token: app.globalData.access_token
        },
        success: success,
        fail: fail
    });
}

/**
 * 茶室包间列表
 */
export function chashibaojianlist(params, success, fail = null) {
    uni.request({
        url: domain + '/index?s=/shared/platform.house/index',
        method: 'POST',
        data: {
            ...params,
            access_token: app.globalData.access_token
        },
        success: success,
        fail: fail
    });
}

/**
 * 开灯 关灯
 */
export function cleancontrollerElectricity(params, success, fail = null) {
    uni.request({
        url: domain + '/index?s=/shared/store.house_door/electricity',
        method: 'POST',
        data: {
            ...params,
            access_token: app.globalData.access_token
        },
        success: success,
        fail: fail
    });
}

/**
 * 开大门+开房间门
 */
export function cleancontrollerOpenDoor(params, success, fail = null) {
    uni.request({
        url: domain + '/index?s=/shared/store.house_door/openDoor',
        method: 'POST',
        data: {
            ...params,
            access_token: app.globalData.access_token
        },
        success: success,
        fail: fail
    });
}

/**
 * 茶室包间新增编辑
 */
export function baojianaddedit(params, success, fail = null) {
    uni.request({
        url: domain + '/index.php?s=/shared/platform.house/edit',
        method: 'POST',
        data: {
            ...params,
            access_token: app.globalData.access_token
        },
        success: success,
        fail: fail
    });
}

/**
 * 经营统计
 */
export function wodestatisticsFromStoreId(params, success, fail = null) {
    uni.request({
        url: domain + '/index.php?s=/shared/store.index/statisticsFromStoreId',
        method: 'POST',
        data: {
            ...params,
            access_token: app.globalData.access_token
        },
        success: success,
        fail: fail
    });
}

/**
 * 用户管理
 */
export function wodeuserlist(params, success, fail = null) {
    uni.request({
        url: domain + '/index.php?s=/shared/platform.user/index',
        method: 'POST',
        data: {
            ...params,
            access_token: app.globalData.access_token
        },
        success: success,
        fail: fail
    });
}

/**
 * 用户管理 充值/扣除
 */
export function woderechargekouchu(params, success, fail = null) {
    uni.request({
        url: domain + '/index.php?s=/shared/platform.user/recharge',
        method: 'POST',
        data: {
            ...params,
            access_token: app.globalData.access_token
        },
        success: success,
        fail: fail
    });
}

/**
 * 用户管理 账单
 */
export function wodezhangdan(params, success, fail = null) {
    uni.request({
        url: domain + '/index.php?s=/shared/platform.user/bill',
        method: 'POST',
        data: {
            ...params,
            access_token: app.globalData.access_token
        },
        success: success,
        fail: fail
    });
}

/**
 * 门店管理 店铺详情
 */
export function mendiandetail(params, success, fail = null) {
    uni.request({
        url: domain + '/index.php?s=/shared/platform.store/info',
        method: 'POST',
        data: {
            ...params,
            access_token: app.globalData.access_token
        },
        success: success,
        fail: fail
    });
}

/**
 * 优惠券 储值卡 列表
 */
export function chuxukalist(params, success, fail = null) {
    uni.request({
        url: domain + '/index.php?s=/shared/platform.recharge/index',
        method: 'POST',
        data: {
            ...params,
            access_token: app.globalData.access_token
        },
        success: success,
        fail: fail
    });
}

/**
 * 优惠券 储值卡 列表
 */
export function youhuiquanlist(params, success, fail = null) {
    uni.request({
        url: domain + '/index.php?s=/shared/platform.coupon/index',
        method: 'POST',
        data: {
            ...params,
            access_token: app.globalData.access_token
        },
        success: success,
        fail: fail
    });
}

/**
 * 优惠券 详情
 */
export function youhuiquandetail(params, success, fail = null) {
    uni.request({
        url: domain + '/index.php?s=/shared/platform.coupon/info',
        method: 'POST',
        data: {
            ...params,
            access_token: app.globalData.access_token
        },
        success: success,
        fail: fail
    });
}

/**
 * 优惠券 储值卡添加/修改
 */
export function yhqczkaddedit(params, success, fail = null) {
    uni.request({
        url: domain + '/index.php?s=/shared/platform.recharge/edit',
        method: 'POST',
        data: {
            ...params,
            access_token: app.globalData.access_token
        },
        success: success,
        fail: fail
    });
}


/**
 * 房态管理 房间列表
 */
export function fangtaifangjianlist(params, success, fail = null) {
    uni.request({
        url: domain + '/index?s=/shared/platform.house/index',
        method: 'POST',
        data: {
            ...params,
            access_token: app.globalData.access_token
        },
        success: success,
        fail: fail
    });
}